<%@ page contentType="text/html; charset=utf-8" %>

<%@ include file="/WEB-INF/jsp/includeCss.jsp"%>
<%@ include file="/WEB-INF/jsp/includeJs.jsp"%>
<%@ include file="/WEB-INF/jsp/includeTaglib.jsp"%>
<sec:accesscontrollist hasPermission="${P_ADMIN_STR}" secureId="${MODULE_ADMIN_CODE}" secureType="${MODULE_ADMIN_TYPE}">

<sec:accesscontrollist hasPermission="${P_ADMIN_STR}" secureId="${MODULE_ADMIN_USR_ACL_CODE}" secureType="${MODULE_ADMIN_USR_ACL_TYPE}">

<script type="text/javascript">
<!--
var setting = {
		view : {
			dblClickExpand : false
		},
		data : {
			simpleData : {
				enable : true
			}
		},
		callback : {
			onDblClick:function(e, treeId, treeNode){
				if(!treeNode.isParent && !treeNode.isEmploy){
					var icon=treeNode.icon;
					treeNode.icon = "<c:url value='/css/zTreeStyle/img/loading.gif' />";
					$.fn.zTree.getZTreeObj(treeId).updateNode(treeNode);
					$.getJSON("<c:url value='/json/findAllChildEmployeesBy.html?orgCode=' />"+treeNode.id, function(jsonData){
						if(jsonData.length>0){
							var zTree = $.fn.zTree.getZTreeObj(treeId);
							for(var i=0;i<jsonData.length;i++){
								jsonData[i].isEmploy=true;
							}
							zTree.addNodes(treeNode, jsonData);
						}else{
							alert('未找到相关数据');
						}

						treeNode.icon = icon;
						$.fn.zTree.getZTreeObj(treeId).updateNode(treeNode);
					});
				}
			},
			onClick:function(e, treeId, treeNode){
				if(treeNode.isEmploy){
					var cityObj = $('#employee');
					cityObj.attr('value', treeNode.name);
					$('#orgnizationEmployee').val(treeNode.id);
				}
			}
		}
	};

//-->
</script>

<form:form commandName="userForm" target="tempFrame" >
<table width="100%" border="0" cellpadding="0" cellspacing="5">
  <tr>
    <td valign="top">
      <table class="dbborder" width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td valign="bottom" class="blueTableBg">&nbsp;配置管理&nbsp;-&nbsp;新增账号</td>
        </tr>
        <tr>
          <td>
            <table width="100%" border="0" cellpadding="0" cellspacing="5">
              <tr>
                <td>
                  <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="dashTopLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashTop" width=100%><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashTopRight"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                    </tr>
                    <tr>
                      <td class="dashLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td align="center">
                        <table width="100%" border="0" cellpadding="0" cellspacing="3">

                          <tr>
                            <td width="114" height="20" class="globalText">帐号</td>
                            <td height="20" class="globalText">
                            	<input id="loginName" type="text" class="txtbox" size="20" name="loginName" value=""/>
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">密码</td>
                            <td height="20" class="globalText">
                            	<input id="password" type="password" class="txtbox" size="20" name="password" value="" />
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">角色</td>
                            <td height="20" class="globalText">
															<form:select path="roleIdSlt">
							               		<form:option value="-1" label="-请选择-"/>
							               		<form:options items="${userForm.roles}" itemValue="id" itemLabel="name" />
						               		</form:select>
                            </td>
                          </tr>
                          <tr>
                            <td width="114" height="20" class="globalText">员工名称 </td>
                            <td height="20" class="globalText">
                            	<input type="hidden" name="orgnizationEmployee" id="orgnizationEmployee"/>
                            	<input readonly="readonly" type="text" name="employeeName" id="employee" class="txtbox" size="20" value="" onclick="javascript:showRadioTree('<c:url value="/json/findAllOrgnizations.html" />',this.id,setting);" />
                            </td>
                          </tr>

                          <tr>
                            <td width="114" height="20" class="globalText">显示名称 </td>
                            <td height="20" class="globalText">
                            	<input id="displayName" type="text" class="txtbox" size="20" name="displayName" value=""/>
                            </td>
                          </tr>

                          <tr>
                            <td width="114" height="20" class="globalText">手机IMEI码</td>
                            <td height="20" class="globalText">
                            	<input id="imei" type="text" class="txtbox" size="20" name="imei" value=""/>
                            </td>
                          </tr>

                          <tr>
                            <td height="20" class="globalText">
                            	<input id="disableImeiValidate" type="checkbox" class="txtbox" name="disableImeiValidate" value="1"/>
                                <label for="disableImeiValidate">不使用手机IMEI登录限制</label>
                            </td>
                          </tr>

                          <tr>
                            <td align="center" colspan="2">
                              <table border="0" cellpadding="0" cellspacing="2">
                                <tr>
                                  <td><input type="button" name="saveBtn" class="btnStyle" value="  保存  "></td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                      </td>
                      <td class="dashRight"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                    </tr>
                    <tr>
                      <td class="dashBottomLeft"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashBottom" width=100%><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                      <td class="dashBottomRight"><img src="<c:url value='/images/spacer.gif' />" width="7" height="7"></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form:form>

<script type="text/javascript">
$(document).ready(function() {
    var userForm = $("form[id=userForm]");
    var saveBtn = userForm.find(":button[name=saveBtn]");

    saveBtn.click(function() {
    	document.getElementById("userForm").action="<c:url value='/auth/doregister.html' />";
    	document.getElementById("userForm").method="post";

		  var loginName = document.getElementById("loginName").value.trim();
			if (validateEmpty(loginName)) {
				alert("帐号 不能为空");
				return false;
			}

	   var password = document.getElementById("password").value.trim();
		 if (validateEmpty(password)) {
				alert("密码 不能为空");
				return false;
		 }

		 userForm.submit();
    });
});

function submitCallbackSuccess(data){
	window.location="<c:url value='/userList.html' />";
}

</script>
</sec:accesscontrollist>
</sec:accesscontrollist>


